﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MINERP.BLL.QC;
using FastReport;

namespace MINERP.QC
{
    public partial class FrmPrintPhotoInfo : Form
    {
        public FrmPrintPhotoInfo()
        {
            InitializeComponent();
        }
        QCBLL _bll=new QCBLL();
        private void textBoxPhotoParcode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == (int)Keys.Enter)
            {
                string photoBarcode = FormatProductCode();
                DataTable table = _bll.GetPhotoInfosByPhotoCode(photoBarcode);
             
                //dt.WriteXml(@"C:\windows\xmlData\PrintQCReport.xml", XmlWriteMode.WriteSchema);
                Report fasrReport = new Report();
                try
                {
                   
                    fasrReport.Load(Application.StartupPath + @"\Report\照片小票.frx");
                    fasrReport.RegisterData(table, "Table");
                    //fasrReport.Design();
                    //fasrReport.ShowPrintDialog = false;
                    fasrReport.PrintSettings.ShowDialog = false;
                    fasrReport.Print();
                }
                catch
                { 
                }
                textBoxPhotoParcode.Text = "";
            }
        }
        private string FormatProductCode()
        {

            string code = textBoxPhotoParcode.Text.Trim();
            if (string.IsNullOrEmpty(code))
            {
                MessageBox.Show("请输入产品号！", "确认", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            if (code.Length < 10)
            {
                int c = Convert.ToInt32(code);
                code = "3" + string.Format("{0:d9}", c);
            }
            return code;
        }

        private void FrmPrintPhotoInfo_Load(object sender, EventArgs e)
        {

        }


    }
}
